﻿using System;
using System.Collections.Generic; 
using NTTDATA.BEENChina.ResultCertification.Config;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Address
{
   
    [Serializable]
    [VerfityAttribute(Id = "VerfityA0007", Name = "mansion名空格检证", CategoryType = EnumCategoryType.住所, Model = true)]
    public class VerfityA0007 : VerfityOneResult
    {

       

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;
            if (result == null)
            {
                return false;
            }

            if (entryCommon == "30" || entryCommon == "20")
            {
                return false;
            }

            foreach (List<string> rowResult in result)
            {

                foreach (string colReulst in rowResult)
                {
                  
                    bresult = CheckPrefectureAndCity(colReulst);

                    if (bresult)
                    {
                        break;
                    }
                }

                if (bresult)
                {
                    break;
                }

            }
            
           

            if (bresult)
            {
               Console.WriteLine("VerfityA0007");
            }

            return bresult;
        }

        /// <summary>
        /// mansion栏中的番号与后面的记载未加空格时抽出
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        private bool CheckPrefectureAndCity(string result)
        {
            bool bresult = false;
            var splitResult = new Split.SplitEntryResult(ChildImageObject.CategorySetting.DataFormat, result);

            //string prefecture = splitResult.GetPrefecture();
            //string city = splitResult.GetCity();
            //string town = splitResult.GetTown();
           
            // string numberMansion = splitResult.GetNumberMansion();

           // string number = Split.SplitAddressResult.GetNumberResult(numberMansion);

            //判断番号栏是否存在 不是番号栏的结果
           string number = splitResult.GetNumber();

           bresult = Split.SplitAddressResult.CheckNumber(number);

           //判断番号栏 与后面记载是否未加空格
           if (!bresult)
           {
               var numberMansion = splitResult.GetNumberMansion();

               bresult = Split.SplitAddressResult.CheckSeparator(numberMansion );
           }

            return bresult;
        }

        
    }
}
